﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using TamTreSoSinh.DBContext;

namespace TamTreSoSinh.Admin
{
    public partial class InitDB : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnInitDB_Click(object sender, EventArgs e)
        {
            StreamReader sr = new StreamReader(Server.MapPath(@"/Admin/script_Init.sql"));
            string scriptContent = sr.ReadToEnd();
            DBTamTreEntities dbContext = new DBTamTreEntities();
            dbContext.ExecuteStoreCommand(scriptContent);
            dbContext.SaveChanges();
        }

        protected void btnUpdateDB_Click(object sender, EventArgs e)
        {
            StreamReader sr = new StreamReader(Server.MapPath(@"/Admin/script_Update.sql"));
            string scriptContent = sr.ReadToEnd();
            DBTamTreEntities dbContext = new DBTamTreEntities();
            dbContext.ExecuteStoreCommand(scriptContent);
            dbContext.SaveChanges();
        }
    }
}